import { mapState, mapActions } from 'vuex'

const mixin = {
  computed: {
    ...mapState({
      menuNavTab: state => state.app.menuNavTab,
      selectOrder: state => state.blog.selectOrder,
      blogType: state => state.blog.blogType,
      blogTag: state => state.blog.blogTag,
      currentType: state => state.blog.currentType,
      currentTag: state => state.blog.currentTag,
      blogList: state => state.blog.blogList,
      blogDetail: state => state.blog.blogDetail
    }),
    currentType: {
      get() {
        // console.log("当前博客类型是"+this.$store.state.blog.currentType)
        return this.$store.state.blog.currentType
      },
      set(val) {
        // console.log("博客类型变化了:" + val)
        this.$store.commit('setCurrentType', val)
      }
    },
    currentTag: {
      get() {
        return this.$store.state.blog.currentTag
      },
      set(val) {
        this.$store.commit('setCurrentTag', val)
      }
    },
    blogType: {
      get() {
        return this.$store.state.blog.blogType
      },
      set(val) {
        this.$store.commit('setBlogType', val)
      }
    },
    blogTag: {
      get() {
        return this.$store.state.blog.blogTag
      },
      set(val) {
        this.$store.commit('setBlogTag', val)
      }
    },
    selectOrder: {
      get() {
        return this.$store.state.blog.selectOrder
      },
      set(val) {
        this.$store.commit('setSelectOrder', val)
      }
    },
    menuNavTab: {
      get() {
        return this.$store.state.app.menuNavTab
      },
      set(val) {
        this.$store.commit('setMenuNavTab', val)
      }
    }
  },
  methods: {
    ...mapActions(['refreshBlogs'])
  }
}

export { mixin }
